package com.changgou.exception;

import com.changgou.entity.Result;
import com.changgou.entity.StatusCode;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

@ControllerAdvice
public class ExceptionCatch {
    private static final Logger LOGGER = LoggerFactory.getLogger(ExceptionCatch.class);






    @ExceptionHandler(Exception.class)
    @ResponseBody
    public Result exception(Exception e) {

        LOGGER.error("catch exception : {}\r\nexception: ", e.getMessage(), e);


        return  new Result(false,StatusCode.ERROR,e.getMessage());
    }

}
